import request from '@/config/axios'
import type { TransactionDetail } from './types'

export const getTransactionDetailsListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/transaction-details', params })
}

export const createTransactionDetailsApi = (
  data: Partial<TransactionDetail>
): Promise<IResponse> => {
  return request.post({ url: '/transaction-details', data })
}

export const updateTransactionDetailsApi = (
  id: string,
  data: Partial<TransactionDetail>
): Promise<IResponse> => {
  return request.put({ url: `/transaction-details/id/${id}`, data })
}

export const getTransactionDetailsDetailApi = (
  id: string
): Promise<IResponse<TransactionDetail>> => {
  return request.get({ url: `/transaction-details/id/${id}` })
}

export const delTransactionDetailsListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/transaction-details/id/${ids[0]}` })
}

export const printConsumeApi = (
  data: Partial<TransactionDetail>,
  mode?: string
): Promise<IResponse> => {
  return request.post({ url: `/transaction-details/print-consume?mode=${mode}`, data })
}

export const printValueAddApi = (data: Partial<TransactionDetail>): Promise<IResponse> => {
  return request.post({ url: `/transaction-details/print-value-add`, data })
}
